package cn.com.sparkle.paxos.event;

public abstract class CatchUpEvent implements Event {
	public final static int FAIL_CATCH_UP = 1;
	public final static int RECOVERY_FROM_CATCH_UP = 2;

	@Override
	public void event(Object... args) {
		switch ((Integer) args[0]) {
		case FAIL_CATCH_UP:
			catchUpFail();
			break;
		case RECOVERY_FROM_CATCH_UP:
			recoveryFromFail();
			break;
		default:
			throw new RuntimeException("Not support event argument!");
		}
	}

	public final static void doCatchUpFailEvent(EventsManager eventsManager) {
		eventsManager.doEvent(CatchUpEvent.class, FAIL_CATCH_UP);
	}

	public final static void doRecoveryFromFailEvent(EventsManager eventsManager) {
		eventsManager.doEvent(CatchUpEvent.class, RECOVERY_FROM_CATCH_UP);
	}

	public abstract void catchUpFail();

	public abstract void recoveryFromFail();

}
